#include "StdAfx.h"
#include "StandarPageWnd.h"
//#include "..\StormWidgetUILibrary\DialogBuilder.h"
//#include "..\StormWidgetUILibrary\WindowWnd.h"
#include "..\StormWidgetUILibrary\UIlib.h"


CStandarPageWnd::CStandarPageWnd(void)
{
}

CStandarPageWnd::~CStandarPageWnd(void)
{
}

UINT CStandarPageWnd::GetClassStyle() const
{
	return UI_CLASSSTYLE_CHILD;
}

void CStandarPageWnd::OnFinalMessage(HWND hWnd)
{
	delete this;
}

LRESULT CStandarPageWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if(uMsg == WM_CREATE)
	{
		m_pm.Init(m_hWnd);
		CDialogBuilder builder;
		CControlUI* pRoot = builder.Create(GetDialogResource());
		ASSERT(pRoot && "Failed to parse XML");
		m_pm.AttachDialog(pRoot);
		m_pm.AddNotifier(this);
		Init();
		return 0;
	}
	/*else if(uMsg == WM_NCHITTEST)
	{
		::SendMessage(GetParent(m_hWnd),WM_NCHITTEST,wParam,lParam);
	}*/
	//else if(uMsg == WM_LBUTTONDOWN)
	//{
	//	//MessageBox(m_hWnd,L"",L"",MB_OK);
	//	::SendMessage(GetParent(m_hWnd),WM_LBUTTONDOWN,wParam,lParam);
	//}
	
	LRESULT lRes = 0;
	if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}

void CStandarPageWnd::Init()
{
}

void CStandarPageWnd::OnPrepareAnimation()
{
}

void CStandarPageWnd::Notify(TNotifyUI& msg)
{
	if( msg.sType == _T("windowinit") ) OnPrepareAnimation();
}